/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufpe.cin.dsoa.visualvm.domain;

import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;

/**
 * This class represents a "NFR"
 * @author rafael.lima
 */


public class QoSCategory {

    private String name;
    private Collection<QoSCharacteristic> characteristics;
    
    public QoSCategory(String nome){
        
        this.name = nome;
        this.characteristics = new Vector<QoSCharacteristic>();
                     
    }
    
    public QoSCategory(String nome, Collection<QoSCharacteristic> chars){
        this.name = nome;
        this.characteristics = chars;
    }

    public String getName() {
        return name;
    }

    public void setName(String nome) {
        this.name = nome;
    }
    
    public void addCharacteristic(QoSCharacteristic c){
        this.characteristics.add(c);
    }
    
    public void removeCharacteristic(QoSCharacteristic c){
        this.characteristics.remove(c);
    }
    
    public void setCharacteristics(Collection<QoSCharacteristic> chars){
        this.characteristics = chars;
    }
    
    public Collection<QoSCharacteristic> getCharacteristics(){
        return this.characteristics;
    }
    
    public String getID(){
    	return this.getName();
    }
    
    @Override
    public String toString(){
        return this.name;
    }
    
    @Override
    public boolean equals(Object o){
    	
    	boolean ret = false;
    	
    	ret = o != null && o instanceof QoSCategory && ((QoSCategory)o).getName().equals(this.getName());
    	
    	return ret;
    }

    public QoSCharacteristic getQosCharacteristic(String toString) {
        
        QoSCharacteristic ret = null;
        boolean stop = false;
        Iterator<QoSCharacteristic> it = this.characteristics.iterator();
        
        while(!stop && it.hasNext()){
            ret = it.next();
            stop = ret.getID().equals(toString);
            
        }
        
        return ret;
    }

}
